﻿///<reference path="../jquery-1.4.1.min.js" />
///<reference path="../jquery.validate.min.j" />
///<reference path="../jquery.validate.rules.js" />

$(function () {
    $('.submit-link').click(function (e) {
        e.preventDefault();
        $(this).parents("form:first").submit();
    })
});

var validation_rules = {
    onfocuseout: true,
    rules: { Shipping: { required: true }, Payment: { required: true} },
    messages: { Shipping: { required: 'Please select a shipping method' }, Payment: { required: 'Please select a payment method'} },
    errorPlacement: function (error, element) {
        if (element.attr("name") == "Shipping") {
            $(".error_container_row").show();
            $(".error_container_row .error_container").append(error);
        } else if (element.attr("name") == "Payment") {
            $(".payment_error_container_row").show();
            $(".payment_error_container_row .error_container").append(error);
        }
        else {
            error.insertAfter(element);
        }
    }
};

$(document).ready(function () {
    $("#payment_form").validate(validation_rules);
});